Thread: warning: passing arg 2 of `execv' from incompatible pointer type

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    1,012
    The argument list to execv() must be NULL terminated--you need a NULL pointer right after your last argument. Something like firstargs[countr + 1] = NULL, before you execv(), should work.

    Also, fgets(), unlike gets(), stores the newline it reads. You'll want to find it (with strchr()) and remove it, if it exists.

  2. #2
    Registered User
    Join Date
    Nov 2010
    Posts
    4
    The argument list to execv() must be NULL terminated--you need a NULL pointer right after your last argument. Something like firstargs[countr + 1] = NULL, before you execv(), should work.

    Also, fgets(), unlike gets(), stores the newline it reads. You'll want to find it (with strchr()) and remove it, if it exists.
    Thank you so much for your help. My code is now working ( I had a few logic bugs to work out on my own). I do have some general language questions from this if you (or someone else from here) wouldn't mind answering.

    What exactly is the difference between *char and char[]? from my understanding when you declare
    char c[10];
    then c is a pointer to the first element in the array, and can be accessed like a pointer *c.

    By extension: how come when creating int main() you can write:
    Code:
    int main(int argc, char* argv[])
    and
    Code:
    int main(int argc char** argv)
    and access argv in the program in the same way, as in
    Code:
    char array[] = argv[1];
    even though they are different data structures?

    Thanks again.
    -luro

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 09-16-2009, 06:00 AM
  2. Replies: 4
    Last Post: 04-21-2008, 12:15 PM
  3. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM

Tags for this Thread